package com.kh.first;

import java.util.ArrayList;
import java.util.List;

public class SqlFieldGen {
    public static void main(String[] args) {
        //去顶ct时间，一条线，4台设备
        //每台设备的生产节拍，4道工序，节拍时间，产前准备op0
        // pingjin 3,3:10,3:50
        //瓶颈工序算ct，下班清扫设备，作业时间，除去瓶颈工序
        //mt,设备加工时间,ht，装设备时间
        String[] fields = new String[]{
                "no1WithStep2",
                "no3WithStep1",
                "no3WithStep2",
                "no4WithStep1",
                "no4WithStep2",
        };
        StringBuilder sb = new StringBuilder();
        List<String> fieldList = new ArrayList<>();
        for (String field : fields) {
            fieldList.add(field + "MaterialLostNo");
            fieldList.add(field + "ProcessLostNo");
            fieldList.add(field + "Reason");
        }
        for (String field : fieldList) {
            String sql = String.format("alter table production_report add %s int(3) default null;\n", field);
            if (field.contains("Reason")) {
                sql = String.format("alter table production_report add %s varchar(255) default null;\n", field);
            }
            sb.append(sql);
        }
        System.out.println(sb.toString());

        /**
         * CREATE TABLE `production_report` (
         *   `id` bigint(20) NOT NULL AUTO_INCREMENT,
         *   `dept` varchar(10) COLLATE utf8_bin DEFAULT NULL,
         *   `productionLine` varchar(20) COLLATE utf8_bin DEFAULT NULL,
         *   `packageNumber` varchar(20) COLLATE utf8_bin DEFAULT NULL,
         *   `createTime` datetime DEFAULT NULL,
         *   `schedulingNo` int(2) DEFAULT NULL,
         *   `schedulingCatagory` int(2) DEFAULT NULL,
         *   `startWorkTime` datetime DEFAULT NULL,
         *   `endWorkTime` datetime DEFAULT NULL,
         *   `extraHours` decimal(4,2) DEFAULT NULL,
         *   `semifinishedProductNo` int(4) DEFAULT NULL,
         *   `completeProductNo` int(4) DEFAULT NULL,
         *   `processLostNo` int(4) DEFAULT NULL,
         *   `materialLostNo` int(4) DEFAULT NULL,
         *   `no1WithStep1MaterialLostNo` int(3) DEFAULT NULL,
         *   `no1WithStep1ProcessLostNo` int(3) DEFAULT NULL,
         *   `no1WithStep1Reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
         *   `no1WithStep1` int(3) DEFAULT NULL COMMENT '白/夜班的第一行第一个两小时',
         *   `no1WithStep2` int(3) DEFAULT NULL,
         *   `no2ProcessLostNo` int(3) DEFAULT NULL,
         *   `no2MaterialLostNo` int(3) DEFAULT NULL,
         *   `no2Reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
         *   `no2` int(3) DEFAULT NULL COMMENT '休息完了，工作，然后就吃饭',
         *   `no3WithStep1` int(3) DEFAULT NULL COMMENT '吃完饭干活',
         *   `no3WithStep2` int(3) DEFAULT NULL,
         *   `no4WithStep1` int(3) DEFAULT NULL COMMENT '接近尾声的干活',
         *   `no4WithStep2` int(3) DEFAULT NULL,
         *   PRIMARY KEY (`id`)
         * ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
         */
        /**
         * ithStep1MaterialLostNo` int(3) DEFAULT NULL,
         *   `no1WithStep1ProcessLostNo` int(3) DEFAULT NULL,
         *   `no1WithStep1Reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
         *   `no1WithStep1` int(3) DEFAULT NULL COMMENT '白/夜班的第一行第一个两小时',
         *   `no1WithStep2` int(3) DEFAULT NULL,
         *   `no2ProcessLostNo` int(3) DEFAULT NULL,
         *   `no2MaterialLostNo` int(3) DEFAULT NULL,
         *   `no2Reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
         *   `no2` int(3) DEFAULT NULL COMMENT '休息完了，工作，然后就吃饭',
         *   `no3WithStep1` int(3) DEFAULT NULL COMMENT '吃完饭干活',
         *   `no3WithStep2` int(3) DEFAULT NULL,
         *   `no4WithStep1` int(3) DEFAULT NULL COMMENT '接近尾声的干活',
         *   `no4WithStep2` int(3) DEFAULT NULL,
         *   `no1WithStep2MaterialLostNo` int(3) DEFAULT NULL,
         *   `no1WithStep2ProcessLostNo` int(3) DEFAULT NULL,
         *   `no1WithStep2Reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
         *   `no3WithStep1MaterialLostNo` int(3) DEFAULT NULL,
         *   `no3WithStep1ProcessLostNo` int(3) DEFAULT NULL,
         *   `no3WithStep1Reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
         *   `no3WithStep2MaterialLostNo` int(3) DEFAULT NULL,
         *   `no3WithStep2ProcessLostNo` int(3) DEFAULT NULL,
         *   `no3WithStep2Reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
         *   `no4WithStep1MaterialLostNo` int(3) DEFAULT NULL,
         *   `no4WithStep1ProcessLostNo` int(3) DEFAULT NULL,
         *   `no4WithStep1Reason` varchar(255) COLLATE utf8_bin DEFAULT NULL,
         *   `no4WithStep2MaterialLostNo` int(3) DEFAULT NULL,
         *   `no4WithStep2ProcessLostNo` int(3) DEFAULT NULL,
         *   `no4WithStep2Re
         */
    }
}
